<?php

//Tao MyController
class MyController extends CController
{

    public $layout = '//layouts/main';
    public $menu = array();
    //Khoi tao bien assetDir
    public $assetDir;
    public $breadcrumbs = array();
    public $category;
    public $meta_desc;
    public $meta_keywords;
    public $lang_id = null;
    public $slide_post;
    public $rate;
    public $rates;

    public function filters()
    {
        $this->pageTitle = yii::app()->name = 'Giá Xây Dựng';
        parent::filters();
//        Gan bien baseUrl vao bien assetDir
        $this->assetDir = Yii::app()->theme->baseUrl;
        $this->meta_desc = '';
        $this->meta_keywords = '';

//        if (isset($_GET['lang']))
//            Yii::app()->language = $_GET['lang'];
//
//        $cri = new CDbCriteria();
//        $cri->condition = 'code = :c';
//        $cri->params = array(
//            ':c' => Yii::app()->language
//        );
//        $lang = Language::model()->find($cri);
//        $this->lang_id = $lang->id;
//
//        $cri->condition = 'parent_id = 0 AND language_id =:l AND status !=:s';
//        $cri->params = array(
//            ":l" => $this->lang_id,
//            ":s" => Category::STATUS_DRAFT,
//        );
        $this->category = Category::model()->findAll(array('condition' => 'parent_id = 0'));
//
//        $this->slide_post = Post::model()->findAll(array(
//            "condition" => "status =:s AND language_id=:l",
//            "params" => array(
//                ":s" => Post::STATUS_HIGHLIGHT,
//                ":l" => $this->lang_id
//            )
//            )
//        );

        $this->rates = Exrate::model()->findAll();
        if (isset($_GET['exchange']))
        {
            $this->rate = Exrate::model()->find(array(
                "condition" => 'name=' . "'" . $_GET['exchange'] . "'"
            ));
        }
        else
        {
            $this->rate = Exrate::model()->find(array(
                "condition" => "name='vnd'"
            ));
        }
    }

}
